package main

import (
	"context"

	_ "deepshr/utility/gmigrate/example/migrations"
	_ "deepshr/utility/gmigrate/gress"
	"deepshr/utility/gmigrate/postgres"
	_ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gres"
	"github.com/golang-migrate/migrate/v4"
	//_ "github.com/golang-migrate/migrate/v4/source/file"
)

func main() {
	//db, err := sql.Open("postgres", "postgres://postgres:password123@localhost:5432/postgres?sslmode=disable")
	//if err != nil {
	//	panic(err)
	//}
	gres.Dump()
	driver, err := postgres.WithConnection(context.Background(), g.DB(), &postgres.Config{
		Module: "default",
	})
	if err != nil {
		panic(err)
	}
	m, err := migrate.NewWithDatabaseInstance(
		"gress://migrations",
		"postgres", driver)
	if err != nil {
		panic(err)
	}
	//m.Up()
	m.Down()
	//m, err := migrate.New(
	//	"file://./migrations",
	//	"postgres://postgres:password123@localhost:5432/postgres?sslmode=disable")
	//if err != nil {
	//	panic(err)
	//}
	//if err := m.Down(); err != nil {
	//	panic(err)
	//}
}
